
<template>
    <div v-loading="loading" style="height: 100%;width: 100%;">
      正在加载中...
    </div>
  
  </template>
  
  <script>
  import Cookies from "js-cookie";
  import { giteeLogin} from "@/api/login";
  import {  setToken } from '@/utils/auth'
  
  
  export default {
    name: "loginByGitee",
    data() {
      return {
        loading: true
      }
    },
    mounted() {
      this.loading = true;
      // debugger
      //路由地址中获取回调地址返回的code传参给函数giteeLogin
      giteeLogin(this.$route.query.code).then((res) => {
        //保存token到cookie
        setToken(res.token)
        //保存token到vuex
        this.$store.state.token=res.token;
        //跳转到登录后页面
        this.$router.push({ path: this.redirect || "/" }).catch(()=>{});
      }).catch(() => {
        this.loading = false;
      });
      
    }
  }
  </script>
  
  <style scoped>
  
  </style>
  